package glossos.parsing.fsm;

import glossos.parsing.CharMatcher;
import glossos.parsing.action.Action;

public class Transition {

	private final CharMatcher charMatcher;
	private final Action action;
	private final State targetState;

	public Transition(CharMatcher charMatcher, Action action, State targetState) {
		this.charMatcher = charMatcher;
		this.action = action;
		this.targetState = targetState;
	}
	
    public State trigger(char c){
		action.execute(c);
		return targetState;
	}

	public boolean isDefinedFor(char c){
		return charMatcher.matches(c);
	}
}
